/**
 * 
 */
package net.loyintean.pearlshell.logcenter.jms.activemq;

import javax.jms.ConnectionFactory;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;

import net.loyintean.pearlshell.logcenter.jms.IJmsSender;
import net.loyintean.pearlshell.logcenter.jms.IJmsSenderFactory;
import net.loyintean.pearlshell.logcenter.jms.impl.JmsSenderImpl;
import net.loyintean.pearlshell.logcenter.model.IConfigModel;

/**
 * @author Administrator
 * 
 */
public class FixedJmsSenderFactoryImpl extends IJmsSenderFactory {

	private ConnectionFactory factory;

	/**
	 * 
	 * @see net.loyintean.pearlshell.logcenter.jms.impl.IJmsSenderFactory
	 *      #create(java.lang .String, java.lang.String)
	 */
	@Override
	@Deprecated
	public IJmsSender create(String url, String destinationName) {

		factory = new ActiveMQConnectionFactory(
				ActiveMQConnection.DEFAULT_USER,
				ActiveMQConnection.DEFAULT_PASSWORD, url);

		JmsSenderImpl sender = new JmsSenderImpl();
		sender.init(factory, destinationName);

		return sender;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * net.loyintean.pearlshell.logcenter.jms.impl.IJmsSenderFactory#create(com
	 * .sinosig.pearlshell.logcenter.model.IConfigModel)
	 */
	@Override
	public IJmsSender create(IConfigModel config) {
		factory = new ActiveMQConnectionFactory(config.getUserName(),
				config.getPassWord(), config.getUrl());

		JmsSenderImpl sender = new JmsSenderImpl();
		sender.init(factory, config.getDestinationName());

		return sender;
	}

}
